<template>
  <default-layout>
    <header-back text="站内信" slot="header">
      <!--<mt-button slot="right">全部标为已读</mt-button>-->
    </header-back>
    <div
      v-infinite-scroll="loadMore"
      infinite-scroll-disabled="disabledScroll"
      infinite-scroll-distance="10"
      infinite-scroll-immediate-check="false"
      slot="main"
      class="scroll-view">
      <div class="list">
        <div class="item" @click="handleClick" v-for="(val, key) in list" :key="key">
          <div class="date">{{val.receiveDate}}</div>
          <div class="tit">{{val.messContType}}</div>
          <div class="con">
            <span>{{val.messCont}}</span>
          </div>
        </div>
      </div>
      <loading-text v-if="loading"></loading-text>
      <finish-text v-if="noMore"></finish-text>
      <empty v-if="empty"></empty>
      <yd-backtop></yd-backtop>
    </div>
    <transition name="router" mode="out-in">
      <router-view class="fixed-router"></router-view>
    </transition>
  </default-layout>
</template>
<script>
  import HeaderBack from '../../../components/header-back/header-back.vue'
  import LoadingText from '../../../components/loading-text/loading-text.vue'
  import FinishText from '../../../components/finish-text/finish-text.vue'
  import DefaultLayout from '../../../layouts/default-layout/default-layout'
  import {infinite} from '../../../common/js/mixin'
  import Empty from '../../../components/empty/empty'

  export default {
    components: {
      Empty,
      DefaultLayout,
      FinishText,
      LoadingText,
      HeaderBack},
    computed: { ...infinite },
    data() {
      return {
        /* 以下五个参数为上拉加载页面必需的参数 */
        loading: true,
        page: 1,
        size: 10,
        total: 0,
        list: []
        /* 以上五个参数为上拉加载页面必需的参数 */
      }
    },
    methods: {
      loadMore() {
        if (this.page === 1) this.list = []
        this.$post('/admin/person/sapi/person/center/my/innermessage/list', {
          page: this.page,
          pageSize: this.size
        }, loading => {
          this.loading = loading
        }, false).then(res => {
          this.list = this.list.concat(res.data.dataList)
          this.total = res.data.pageBean.totalCount
          this.page++
        })
      },
      handleClick() {
        // detail
      }
    },
    created() {
      this.loadMore()
    }
  }
</script>
<style lang="scss" scoped>
  @import "../../../common/style/variable";
  .list{
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .item{
    width: 95%;
    background: #fff;
    border-radius: 8px;
    padding: .2rem;
    margin: .6rem 0 0 0;
    position: relative;
    @include active;
    .date{
      position: absolute;
      padding: 0 0 .1rem 0;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
    }
    .tit{
      font-size: .33rem;
      color: #000;
    }
    .con{
      padding: .2rem 0 0 0;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: .28rem;
      color: #666;
    }
  }
</style>
